package com.huabo.contract.mysql.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.contract.mysql.entity.TblContractInvoicesmanagemenMySql;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.BaseMapper;

import java.math.BigDecimal;
import java.util.List;

public interface TblContractInvoicesmanagemenMySqlMapper extends BaseMapper<com.huabo.contract.mysql.entity.TblContractInvoicesmanagemenMySql> {

    @SelectProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "findInvoiceInfoListForCollection")
    List<TblContractInvoicesmanagemenMySql> findInvoiceInfoListForCollection(PageInfo<TblContractInvoicesmanagemenMySql> pageInfo, TblContractInvoicesmanagemenMySql invoice);

    @SelectProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "findInvoiceInfoListForCollectionCount")
    Integer findInvoiceInfoListForCollectionCount(TblContractInvoicesmanagemenMySql invoice);

    @SelectProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "findContractInvociesManaeMenPageInfo")
    List<TblContractInvoicesmanagemenMySql> findContractInvociesManaeMenPageInfo(PageInfo<TblContractInvoicesmanagemenMySql> pageInfo, TblContractInvoicesmanagemenMySql invoice);

    @SelectProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "findContractInvociesManaeMenPageInfoCount")
    Integer findContractInvociesManaeMenPageInfoCount(TblContractInvoicesmanagemenMySql invoice);

    @Select("SELECT * FROM TBL_CONTRACT_INVOICESMANAGEMEN TCI\n" +
            "LEFT JOIN TBL_CYHW_PROJECTBUDGET TCP ON TCI.BUDGETID = TCP.BUDGETID\n" +
            "WHERE INVOICEID = #{invoiceid}")
    TblContractInvoicesmanagemenMySql getInvoiceid(BigDecimal invoiceid);

    @SelectProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "selectListCount")
    Integer selectListCount(TblContractInvoicesmanagemenMySql oldInvoice);

    @UpdateProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "updateMergenEntity")
    void updateMergenEntity(TblContractInvoicesmanagemenMySql oldInvoice);

    @InsertProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "saveMergenEntity")
    @Options(useGeneratedKeys = true, keyProperty = "invoiceid", keyColumn = "INVOICEID")
    void saveMergenEntity(TblContractInvoicesmanagemenMySql oldInvoice);

    @Update("UPDATE TBL_CONTRACT_INVOICESMANAGEMEN SET INVOICESTATUS = #{status} WHERE INVOICEID = #{invoiceId}")
    void updateModifyInvoiceStatus(Integer invoiceId, Integer status);

    @Delete("DELETE FROM TBL_CONTRACT_INVOICESMANAGEMEN WHERE INVOICEID = #{invoiceId}")
    void removeInvoiceInfo(Integer invoiceId);

    @InsertProvider(type = TblContractInvoicesmanagemenMapperSqlMySqlConfig.class, method = "saveInvoicemanageMenTci")
    void saveInvoicemanageMenTci(TblContractInvoicesmanagemenMySql tci);

}
